#include "DisplayController.h"
#include "SleepTimer.h"
#include <QWidget>

DisplayController::DisplayController()
{
	_timeScale = 1;
	_continousDisplay.setController(this);

}

void DisplayController::showDisplay()
{
	_continousDisplay.resize(300,200);
	_continousDisplay.showMaximized();
}

void DisplayController::addHistory(History* pHistory)
{
	_histories.push_back(pHistory);
}

void DisplayController::setTimeScale(int timeScale)
{
	_timeScale = timeScale;
}

void DisplayController::Redraw()
{
	for (unsigned int i = 0; i < _histories.size(); i++)
	{
		_continousDisplay.drawSignal(_histories[i], _timeScale);
	}
}

void DisplayController::run()
{
	SleepTimer timer;
	while(1) {
		_continousDisplay.repaint(); //synchronous
//		_continousDisplay.update();
		timer.sleep(20);
	}
}
